<template>
    <div style="background: #fff; width: 100%">
        <a-tabs type="card" v-model:activeKey="activeKey" v-if="isRenderComponent">
            <a-tab-pane key="1" tab="北极星指标">
                <div style="padding: 16px">
                    <div>
                        <flexbox>
                            <img src="@/assets/images/beijixing/beijixing-icon.png" style="width: 24px" />
                            <span class="margin-l-8 font-w-b">指标公式拆分</span>
                        </flexbox>
                        <div style="color: #70798b" class="margin-t-8"
                            >拆分因子可靠性分析：黄色警告项越多代表数据录入规范性越差，指标可靠性越低；绿色项越多代表指标可靠性越高</div
                        >
                        <div style="margin-top: 24px; font-size: 16px">需求交付周期 = 需求上线时间 - 需求创建时间</div>

                        <flexbox
                            justify="space-between"
                            style="width: 70%"
                            :class="[detail.wrongTimeIndex && detail.wrongTimeIndex.length ? 'warning-cont' : 'success-cont', 'margin-t-16']"
                        >
                            <flexbox>
                                <ExclamationCircleFilled style="color: #faad14" v-if="detail.wrongTimeIndex && detail.wrongTimeIndex.length" />
                                <CheckCircleFilled style="color: #52c41a" v-else />
                                <span class="margin-l-8">需求跟踪矩阵异常</span>
                                <a
                                    class="margin-l-16"
                                    style="text-decoration: underline"
                                    @click="jumpTo"
                                    v-if="detail.wrongTimeIndex && detail.wrongTimeIndex.length"
                                    >{{ detail.wrongTimeIndex.length }}条</a
                                >
                                <span class="margin-l-16" v-else>0</span>
                            </flexbox>
                            <span style="color: #70798b">影响指标：交付周期等阶段周期不准确</span>
                        </flexbox>
                        <flexbox justify="space-between" style="width: 70%" class="warning-cont margin-t-16">
                            <flexbox>
                                <ExclamationCircleFilled style="color: #faad14" />
                                <span class="margin-l-8">使用JIRA管理项目，研发过程没有流程卡点，数据依赖各项目开发录入习惯</span>
                            </flexbox>
                            <span style="color: #70798b">影响指标：研发阶段时间不准确、测试阶段时间不准确</span>
                        </flexbox>

                        <flexbox justify="space-between" style="width: 70%" class="warning-cont margin-t-16">
                            <flexbox>
                                <ExclamationCircleFilled style="color: #faad14" />
                                <span class="margin-l-8">缺失需求提出、需求受理、需求分析、需求转化阶段管理数据</span>
                            </flexbox>
                            <span style="color: #70798b">影响指标：需求提出时间缺失、交付周期不准确</span>
                        </flexbox>

                        <flexbox justify="space-between" style="width: 70%" class="warning-cont margin-t-16">
                            <flexbox>
                                <ExclamationCircleFilled style="color: #faad14" />
                                <span class="margin-l-8">版本上线时间非必填，数据准确性依赖项目负责人的录入情况</span>
                            </flexbox>
                            <span style="color: #70798b"> 影响指标：需求上线时间不准确、交付周期不准确</span>
                        </flexbox>
                    </div>
                </div>
                <ZhiBiaoChaifen :detail="detail" style="margin-top: 32px" />
                <ZhiBiaoTongjiTable :detail="detail" v-if="detail.id && route.query.type === '1'" style="margin-top: 32px" />
            </a-tab-pane>
            <a-tab-pane key="2" tab="过程指标"> <div style="padding: 16px">暂无数据</div> </a-tab-pane>
        </a-tabs>
    </div>
</template>

<script lang="ts">
import ZhiBiaoChaifen from './components/ZhiBiaoChaifen.vue';
import ZhiBiaoTongjiTable from '@/views/energyManage/beijixing/Detail/components/ZhiBiaoTongjiTable/index.vue';
import { useRouter, useRoute } from 'vue-router';
import { ExclamationCircleFilled, CheckCircleFilled } from '@ant-design/icons-vue';
import { defineComponent, reactive, toRefs } from 'vue';
import { useIsRenderComponent } from '@/hooks/useIsRenderComponent';

interface State {
    activeKey: string;
}

export default defineComponent({
    name: 'JiraDetail',
    components: {
        ZhiBiaoChaifen,
        ZhiBiaoTongjiTable,
        ExclamationCircleFilled,
        CheckCircleFilled
    },
    props: {
        detail: {
            type: Object,
            default: () => ({})
        }
    },
    setup() {
        const router = useRouter();
        const route = useRoute();
        const { isRenderComponent } = useIsRenderComponent();

        const state = reactive<State>({
            activeKey: '1'
        });

        const jumpTo = () => {
            router.push({
                path: '/energyManage/beijixing/detail/jiraTrack',
                query: {
                    ...route.query
                }
            });
        };

        return {
            ...toRefs(state),
            isRenderComponent,
            jumpTo,
            route
        };
    }
});
</script>

<style scoped lang="less">
.page-wrap {
    position: relative;
    height: 100%;
    .page-header-wrap {
        background: #fff;
        position: sticky;
        top: 0;
        z-index: 9;
        border-bottom: 1px solid #f1f1f1;
        border-top: 1px solid #f1f1f1;
        margin-bottom: 24px;
        &::before {
            content: '';
            position: absolute;
            width: 6px;
            height: 100%;
            background: #3094e9;
            top: 0;
            left: 0;
            z-index: 1;
        }
        .extra-wrap {
            position: absolute;
            right: 40px;
            bottom: 22px;
            color: #000;
            cursor: pointer;
        }
    }
}
.section-wrap {
    padding: 0;
}
// // 去掉表头颜色
::v-deep(.ant-tabs.ant-tabs-card .ant-tabs-card-bar .ant-tabs-tab) {
    margin-right: 0px !important;
    border: none;
    background: #edeff3;
    border-radius: 0;
}
::v-deep(.ant-tabs.ant-tabs-card .ant-tabs-card-bar .ant-tabs-tab-active) {
    background: #fff;
    border-radius: 4px 4px 0px 0px;
}

.warning-cont {
    color: #505a6e;
    background: #fff7e6;
    border: 1px solid #ffe58f;
    padding: 6px 12px;
    font-size: 14px;
    border-radius: 4px;
}
.success-cont {
    color: #505a6e;
    background: #f6ffed;
    border: 1px solid #b7eb8f;
    padding: 6px 12px;
    font-size: 14px;
    border-radius: 4px;
}
</style>
